﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libs.Content;

public partial class Controls_Home_NewsCate : System.Web.UI.UserControl
{
    public int CateID { get; set; }
    public int RowNumber { get; set; }
    public int CharLenght { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        NewsWeb _NewsWeb = new NewsWeb();
        List<NewsWeb> list;

        list = _NewsWeb.GetList(CateID, 0, RowNumber);
        _NewsWeb = list[0];
        if (_NewsWeb.SubLead.Length > CharLenght)
        {
            _NewsWeb.SubLead = _NewsWeb.SubLead.Substring(0, CharLenght) + "...";
        }
        if (string.IsNullOrEmpty(_NewsWeb.ImageUrl))
        {
            ltrNews.Text = Resources.Template.HomeCate;
        }
        else
        {
            ltrNews.Text = Resources.Template.HomeCateImg;
            ltrNews.Text = ltrNews.Text.Replace("$ImageUrl$", AppUtils.ImageUrl(_NewsWeb.ImageUrl, "129", "80"));
        }
        ltrNews.Text = ltrNews.Text.Replace("$Link$", _NewsWeb.Url);
        ltrNews.Text = ltrNews.Text.Replace("$Title$", _NewsWeb.Title);
        ltrNews.Text = ltrNews.Text.Replace("$Lead$", _NewsWeb.SubLead);

        list.RemoveAt(0);
        rptList.DataSource = list;
        rptList.DataBind();
    }
}